<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>add-资产录入</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
	<script type="text/javascript" src="../frame/assets/js/lib/jquery.min.js"></script>
	<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
	<script src="../frame/layui/lay/modules/layer.js"></script>
    <link rel="stylesheet" href="../frame/layui/lay/modules/layer/default/layer.css">
    <link rel="stylesheet" href="../frame/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="../frame/assets/css/lib/bootstrap.min.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/font-awesome.min.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/themify-icons.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/unix.css">
    <link rel="stylesheet" href="../frame/assets/css/style.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/menubar/sidebar.css">
    <link rel="stylesheet" href="../frame/assets/css/lib/sweetalert/sweetalert.css">
    <style>
    .dd{
    	color:#ff0000;
    	padding-left:30px;
    	front-size:12px;
    }
    </style>
</head>

<body style="margin-left:25%;height: 1200px;">
<!--内容-->
<div class="content-wrap" >
    <div class="main">
        <div class="container-fluid">
            <!--欢迎栏-->
            <div class="row">
                <div class="col-lg-8 p-r-0 title-margin-right">
                    <div class="page-header">
                        <div class="page-title">
                            <h1>资产录入</h1>
                             
                        </div>
                    </div>
                </div>
            </div>
            
              <h4><i class="layui-icon layui-icon-face-smile" style="font-size: 30px; color: #1E9FFF;"></i>  添加资产</h4><br><br>
              <div class="layui-text" style="font-size:18px">
                <label>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
				<input type="text" name="id" id="id" onblur="checkp1()">
				<div class="dd" id="p1"></div>
				<label>例如&nbsp;：p01(p+序号)</label>
				<br><br>
				<label>资产编码&nbsp;：</label>
				<input type="text" name="zcid" id="zcid" onblur="check2()">
				<div class="dd" id="p2"></div>
				<label>例如&nbsp;：zc01(zc+序号)</label>
				<br><br>
				<label>资产名称&nbsp;：</label>
				<input type="text" name="zcname" id="zcname" onblur="check3()">
				<div class="dd" id="p3"></div>
				<label>例如&nbsp;：空调</label>
				<br><br>
				<label>资产金额&nbsp;：</label>
				<input type="text" name="money" id="money" onblur="check4()">
				<div class="dd" id="p4">
				</div>
				<label>例如&nbsp;：3200(p+序号)</label>
				<br><br>
				<label>资产大类&nbsp;：</label>
				<input type="text" name="zcclass" id="zcclass" onblur="check5()">
				<div class="dd" id="p5">
				</div>
				<label>例如&nbsp;：家电类(产品的类别,)</label><br>
				<label>可供选择&nbsp;：</label><br>
				<label>&nbsp;1.运输类</label><label>&nbsp;2.办公类</label>
				<label>&nbsp;3.办公类</label><label>&nbsp;4.影视类</label>
				<label>&nbsp;5.工具类</label><label>&nbsp;6.医疗类</label>
				<label>&nbsp;7.家电类</label><label>&nbsp;等等</label>
				<br><br>
				<label>审核人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：</label>
				<input type="text" name="zcperson" id="zcperson" onblur="check6()">
				<div class="dd" id="p6"></div>
				<label>例如&nbsp;：张三</label>
				<br><br>
				<label>购置日期&nbsp;：</label>
				<input type="text" name="begint" id="begint" onblur="check7()">
				<div class="dd" id="p7"></div>
				<label>例如&nbsp;：2021-07-17(xxxx-xx-xx)</label>
				<br><br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				
				<input type="submit" id="submit" onclick="submitp()">
			  </div>
        </div>
    </div>
</div>
<!--搜索-->
<div id="search">
    <button type="button" class="close">×</button>
    <form>
        <input type="search" value="" placeholder="type keyword(s) here" />
        <button type="submit" class="btn btn-primary">Search</button>
    </form>
</div>
</body>
<script src="../frame/assets/js/lib/jquery.nanoscroller.min.js"></script>
<script src="../frame/assets/js/lib/menubar/sidebar.js"></script>
<script src="../frame/assets/js/lib/bootstrap.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/datatables.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/dataTables.buttons.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.flash.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/jszip.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/pdfmake.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/vfs_fonts.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.html5.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/buttons.print.min.js"></script>
<script src="../frame/assets/js/lib/data-table2/datatables-init2.js"></script>
<script src="../frame/assets/js/lib/sweetalert/sweetalert.min.js"></script>
<script src="../frame/assets/js/lib/sweetalert/zhuxiao.js"></script>

<script type="text/javascript">
	function checkp1()
	{
		var user=document.getElementById("id");
		var userid=document.getElementById("p1");
		
		   if(user.value=="")
		   {
			  userid.innerHTML="用户名不能为空";
			   return false;
			}
			if(user.value.length<2 || user.length>10)
			{
			 userid.innerHTML="用户名长度为在3—10字符";
			 return false;
			
			}
			for(var i=0;i<user.value.length;i++)
			{
			var char=user.value.toLowerCase().charAt(i);
			  if((i==0&&(char!='p'))||i!=0&&(!(char>=0 && char<=9)))
			  {
				userid.innerHTML="用户名必须由字母、数字组成";
				return false;
			  }
				
			}
		return true;
	}	 
			  
	function check2(){
	  //编码
	  	var user=document.getElementById("zcid");
		  var userid=document.getElementById("p2");
			   if(user.value==""){
				   userid.innerHTML="编码不能为空";
				   return false;
				}
				if(user.value.length<3 || user.value.length>10){
				 userid.innerHTML="编码名长度为在4—10字符";
				 return false;
				
				}
				for(var i=0;i<user.value.length;i++){
				var char=user.value.toLowerCase().charAt(i);
				  if((i==0&&(char!='z'))||(i==1&&(char!='c'))){
					userid.innerHTML="编码名必须由字母、数字组成";
					return false;
					}
				  else if(i>1){
					  if(!(char>=0 && char<=9)){
						 userid.innerHTML="编码名必须由字母、数字组成";
					  return false;
					  }
				  }
				}
				return true;
	}
	//名称
	function check3()
	{
		var user=document.getElementById("zcname");
		var userid=document.getElementById("p3");
				   if(user.value==""){
					   userid.innerHTML="名称不能为空";
					   return false;
					}
				   return true;
	}
	//金额
	function check4(){
			var user=document.getElementById("money");
		var userid=document.getElementById("p4");	
				   userid.innerHTML="";
				   if(user.value==""){
					   userid.innerHTML="金额不能为空";
					   return false;
					}
				   return true;
	}
	//大类
	function check5(){
		var user=document.getElementById("zcclass");
		var userid=document.getElementById("p5d");	
				   userid.innerHTML="";
				   if(user.value==""){
					   userid.innerHTML="类别不能为空";
					   return false;
					}
				   return true;
				}
	//审核人
	function check6(){
		var user=document.getElementById("zcperson");
		var userid=document.getElementById("p6");	
				   userid.innerHTML="";
				   if(user.value==""){
					   userid.innerHTML="审核人不能为空";
					   return false;
					}
				   return true;
	}
	//日期
	function check7(){
				   var user=begint;	
				   var userid=$("p7");	
				   userid.innerHTML="";
				   if(user.value==""){
					   userid.innerHTML="日期不能为空";
					   return false;
					}
				   if(user.value.length<1 || user.value.length>10){
						 userid.innerHTML="编码名长度为在4—10字符";
						 return false;
						
						}
				   for(var i=0;i<user.value.length;i++){
						var char=user.value.toLowerCase().charAt(i);
						  if((i==4&&(char!='-'))||(i==7&&(char!='-'))){
							userid.innerHTML="日期格式错误";
							return false;
							}
						}
		return true;
	}
				 
			
			
	
	function submitp(){
		
		var id=$("#id").val();
		var zcid=$("#zcid").val();
		var zcname=$("#zcname").val();
		var money=$("#money").val();
		var zcclass=$("#zcclass").val();
		var zcperson=$("#zcperson").val();
		var begint=$("#begint").val(); 
		 $.ajax({
			    url:'addproduct?id='+id+"&zcid="+zcid+"&zcname="+zcname+"&money="+money+"&zcclass="+zcclass+"&zcperson="+zcperson+"&begint="+begint ,
				type:'POST',
				contentType:'application/json;charset=utf-8',
				dataType:'html',
				data:{
					'id':id,
					'zcid':zcid,
					'zcname':zcname,
					'money':money,
					'zcclass':zcclass,
					'zcperson':zcperson,
					'begint':begint
				},
				success:function(res){
					layer.msg("添加成功!");
					alert("成功");
				},
				error:function(res){
					layer.msg("添加失败！");
					alert("失败");
				}
			})
	
	}

</script>
</html>
